package com.hlyj.http.base.tool.lib_hlyj_base.utils;

import com.google.gson.Gson;
import com.tencent.mmkv.MMKV;

public class MMKVUtils {
    private static MMKV mmkv = MMKV.defaultMMKV();
    private static Gson gson = new Gson();

    // 存储对象
    public static <T> void saveObject(String key, T object) {
        String json = gson.toJson(object);
        mmkv.encode(key, json);
    }
    // 读取对象
    public static <T> T getObject(String key, Class<T> classOfT) {
        String json = mmkv.decodeString(key);
        return gson.fromJson(json, classOfT);
    }
}
